import 'package:dio/dio.dart';

/// header拦截器
class HeaderInterceptors extends InterceptorsWrapper {
  late int? _orgId;
  late int? _projectId;
  late int? _userId;

  @override
  onRequest(RequestOptions options, handler) async {
    try {
      options.headers["orgId"] ??= _orgId;
      options.headers["projectId"] ??= _projectId;
      options.headers["userId"] ??= _userId;
    } catch (e) {
      print("HeaderInterceptors ${e}");
    }
    return super.onRequest(options, handler);
  }

  void setHeaderId({required int orgId, required int projectId, required int userId}) {
    _orgId = orgId;
    _projectId = projectId;
    _userId = userId;
  }
}
